44 #define cmd_VGplus (((((('V' << 8) | 'G') << 8) | '+') << 8) | ' ') // "VG+ " = enable angular velocity packet transmission 45 #define cmd_VGminus (((((('V' << 8) | 'G') << 8) | '-') << 8) | ' ') // "VG- " = disable angular velocity packet transmission 46 #define cmd_DBplus (((((('D' << 8) | 'B') << 8) | '+') << 8) | ' ') // "DB+ " = enable debug packet transmission 47 #define cmd_DBminus (((((('D' << 8) | 'B') << 8) | '-') << 8) | ' ') // "DB- " = disable debug packet transmission 48 #define cmd_Q3 (((((('Q' << 8) | '3') << 8) | ' ') << 8) | ' ') // "Q3 " = transmit 3-axis accelerometer quaternion in standard packet 49 #define cmd_Q3M (((((('Q' << 8) | '3') << 8) | 'M') << 8) | ' ') // "Q3M " = transmit 3-axis magnetic quaternion in standard packet 50 #define cmd_Q3G (((((('Q' << 8) | '3') << 8) | 'G') << 8) | ' ') // "Q3G " = transmit 3-axis gyro quaternion in standard packet 51 #define cmd_Q6MA (((((('Q' << 8) | '6') << 8) | 'M') << 8) | 'A') // "Q6MA" = transmit 6-axis mag/accel quaternion in standard packet 52 #define cmd_Q6AG (((((('Q' << 8) | '6') << 8) | 'A') << 8) | 'G') // "Q6AG" = transmit 6-axis accel/gyro quaternion in standard packet 53 #define cmd_Q9 (((((('Q' << 8) | '9') << 8) | ' ') << 8) | ' ') // "Q9 " = transmit 9-axis quaternion in standard packet (default) 54 #define cmd_RPCplus (((((('R' << 8) | 'P') << 8) | 'C') << 8) | '+') // "RPC+" = Roll/Pitch/Compass on 55 #define cmd_RPCminus (((((('R' << 8) | 'P') << 8) | 'C') << 8) | '-') // "RPC-" = Roll/Pitch/Compass off 56 #define cmd_ALTplus (((((('A' << 8) | 'L') << 8) | 'T') << 8) | '+') // "ALT+" = Altitude packet on 57 #define cmd_ALTminus (((((('A' << 8) | 'L') << 8) | 'T') << 8) | '-') // "ALT-" = Altitude packet off 58 #define cmd_RST (((((('R' << 8) | 'S') << 8) | 'T') << 8) | ' ') // "RST " = Soft reset 59 #define cmd_RINS (((((('R' << 8) | 'I') << 8) | 'N') << 8) | 'S') // "RINS" = Reset INS inertial navigation velocity and position 60 #define cmd_SVAC (((((('S' << 8) | 'V') << 8) | 'A') << 8) | 'C') // "SVAC" = save all calibrations to Kinetis flash 61 #define cmd_SVMC (((((('S' << 8) | 'V') << 8) | 'M') << 8) | 'C') // "SVMC" = save magnetic calibration to Kinetis flash 62 #define cmd_SVYC (((((('S' << 8) | 'V') << 8) | 'Y') << 8) | 'C') // "SVYC" = save gyroscope calibration to Kinetis flash 63 #define cmd_SVGC (((((('S' << 8) | 'V') << 8) | 'G') << 8) | 'C') // "SVGC" = save precision accelerometer calibration to Kinetis flash 64 #define cmd_ERAC (((((('E' << 8) | 'R') << 8) | 'A') << 8) | 'C') // "ERAC" = erase all calibrations from Kinetis flash 65 #define cmd_ERMC (((((('E' << 8) | 'R') << 8) | 'M') << 8) | 'C') // "ERMC" = erase magnetic calibration from Kinetis flash 66 #define cmd_ERYC (((((('E' << 8) | 'R') << 8) | 'Y') << 8) | 'C') // "ERYC" = erase gyro offset calibration from Kinetis flash 67 #define cmd_ERGC (((((('E' << 8) | 'R') << 8) | 'G') << 8) | 'C') // "ERGC" = erase precision accelerometer calibration from Kinetis flash 68 #define cmd_180X (((((('1' << 8) | '8') << 8) | '0') << 8) | 'X') // "180X" perturbation 69 #define cmd_180Y (((((('1' << 8) | '8') << 8) | '0') << 8) | 'Y') // "180Y" perturbation 70 #define cmd_180Z (((((('1' << 8) | '8') << 8) | '0') << 8) | 'Z') // "180Z" perturbation 71 #define cmd_M90X (((((('M' << 8) | '9') << 8) | '0') << 8) | 'X') // "M90X" perturbation 72 #define cmd_P90X (((((('P' << 8) | '9') << 8) | '0') << 8) | 'X') // "P90X" perturbation 73 #define cmd_M90Y (((((('M' << 8) | '9') << 8) | '0') << 8) | 'Y') // "M90Y" perturbation 74 #define cmd_P90Y (((((('P' << 8) | '9') << 8) | '0') << 8) | 'Y') // "P90Y" perturbation 75 #define cmd_M90Z (((((('M' << 8) | '9') << 8) | '0') << 8) | 'Z') // "M90Z" perturbation 76 #define cmd_P90Z (((((('P' << 8) | '9') << 8) | '0') << 8) | 'Z') // "P90Z" perturbation 77 #define cmd_PA00 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '0') // "PA00" average precision accelerometer location 0 78 #define cmd_PA01 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '1') // "PA01" average precision accelerometer location 1 79 #define cmd_PA02 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '2') // "PA02" average precision accelerometer location 2 80 #define cmd_PA03 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '3') // "PA03" average precision accelerometer location 3 81 #define cmd_PA04 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '4') // "PA04" average precision accelerometer location 4 82 #define cmd_PA05 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '5') // "PA05" average precision accelerometer location 5 83 #define cmd_PA06 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '6') // "PA06" average precision accelerometer location 6 84 #define cmd_PA07 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '7') // "PA07" average precision accelerometer location 7 85 #define cmd_PA08 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '8') // "PA08" average precision accelerometer location 8 86 #define cmd_PA09 (((((('P' << 8) | 'A') << 8) | '0') << 8) | '9') // "PA09" average precision accelerometer location 9 87 #define cmd_PA10 (((((('P' << 8) | 'A') << 8) | '1') << 8) | '0') // "PA10" average precision accelerometer location 10 88 #define cmd_PA11 (((((('P' << 8) | 'A') << 8) | '1') << 8) | '1') // "PA11" average precision accelerometer location 11 96 for (i = 0; i < nbytes; i++) {
98 for (j = 0; j < 3; j++)
99 iCommandBuffer[j] = iCommandBuffer[j + 1];
100 iCommandBuffer[3] = sUART_InputBuffer[i];
103 isum = ((((((
int32)iCommandBuffer[0] << 8) | iCommandBuffer[1]) << 8) | iCommandBuffer[2]) << 8) | iCommandBuffer[3];
107 iCommandBuffer[3] =
'~';
112 iCommandBuffer[3] =
'~';
117 iCommandBuffer[3] =
'~';
122 iCommandBuffer[3] =
'~';
129 iCommandBuffer[3] =
'~';
136 iCommandBuffer[3] =
'~';
143 iCommandBuffer[3] =
'~';
150 iCommandBuffer[3] =
'~';
157 iCommandBuffer[3] =
'~';
161 #if F_9DOF_GBY_KALMAN 164 iCommandBuffer[3] =
'~';
169 iCommandBuffer[3] =
'~';
174 iCommandBuffer[3] =
'~';
179 iCommandBuffer[3] =
'~';
184 iCommandBuffer[3] =
'~';
199 iCommandBuffer[3] =
'~';
203 #if F_9DOF_GBY_KALMAN 204 for (i =
CHX; i <=
CHZ; i++) {
205 sfg->SV_9DOF_GBY_KALMAN.fVelGl[i] = 0.0F;
206 sfg->SV_9DOF_GBY_KALMAN.fDisGl[i] = 0.0F;
209 iCommandBuffer[3] =
'~';
216 iCommandBuffer[3] =
'~';
221 iCommandBuffer[3] =
'~';
226 iCommandBuffer[3] =
'~';
231 iCommandBuffer[3] =
'~';
238 iCommandBuffer[3] =
'~';
243 iCommandBuffer[3] =
'~';
248 iCommandBuffer[3] =
'~';
253 iCommandBuffer[3] =
'~';
258 iCommandBuffer[3] =
'~';
263 iCommandBuffer[3] =
'~';
268 iCommandBuffer[3] =
'~';
273 iCommandBuffer[3] =
'~';
278 iCommandBuffer[3] =
'~';
283 iCommandBuffer[3] =
'~';
288 iCommandBuffer[3] =
'~';
293 iCommandBuffer[3] =
'~';
298 iCommandBuffer[3] =
'~';
303 sfg->AccelBuffer.iStoreLocation = 0;
305 iCommandBuffer[3] =
'~';
309 sfg->AccelBuffer.iStoreLocation = 1;
311 iCommandBuffer[3] =
'~';
315 sfg->AccelBuffer.iStoreLocation = 2;
317 iCommandBuffer[3] =
'~';
321 sfg->AccelBuffer.iStoreLocation = 3;
323 iCommandBuffer[3] =
'~';
327 sfg->AccelBuffer.iStoreLocation = 4;
329 iCommandBuffer[3] =
'~';
333 sfg->AccelBuffer.iStoreLocation = 5;
335 iCommandBuffer[3] =
'~';
339 sfg->AccelBuffer.iStoreLocation = 6;
341 iCommandBuffer[3] =
'~';
345 sfg->AccelBuffer.iStoreLocation = 7;
347 iCommandBuffer[3] =
'~';
351 sfg->AccelBuffer.iStoreLocation = 8;
353 iCommandBuffer[3] =
'~';
357 sfg->AccelBuffer.iStoreLocation = 9;
359 iCommandBuffer[3] =
'~';
363 sfg->AccelBuffer.iStoreLocation = 10;
365 iCommandBuffer[3] =
'~';
369 sfg->AccelBuffer.iStoreLocation = 11;
371 iCommandBuffer[3] =
'~';
373 #endif // precision accelerometer calibration
Quaternion derived from full 9-axis sensor fusion.
void EraseGyroCalibrationFromNVM(void)
void DecodeCommandBytes(SensorFusionGlobals *sfg, char iCommandBuffer[], uint8 sUART_InputBuffer[], uint16 nbytes)
This function is responsible for decoding commands sent by the NXP Sensor Fusion Toolbox and setting ...
void fInitializeFusion(SensorFusionGlobals *sfg)
void SaveMagCalibrationToNVM(SensorFusionGlobals *sfg)
void fInitializeMagCalibration(MagCalibration *pthisMagCal, MagBuffer *pthisMagBuffer)
Lower level sensor fusion interface.
void SaveAccelCalibrationToNVM(SensorFusionGlobals *sfg)
void EraseMagCalibrationFromNVM(void)
volatile uint8_t AltPacketOn
flag to enable altitude packet
Quaternion derived from 3-axis mag only (auto compass algorithm)
MagCalibration MagCal
mag cal storage
The top level fusion structure.
volatile int8_t AccelCalPacketOn
variable used to coordinate accelerometer calibration
Quaternion derived from 3-axis gyro only (rotation)
Quaternion derived from 3-axis accel + 3 axis mag (eCompass)
Quaternion derived from 3-axis accel + 3-axis gyro (gaming)
struct ControlSubsystem * pControlSubsystem
void SaveGyroCalibrationToNVM(SensorFusionGlobals *sfg)
The sensor_fusion.h file implements the top level programming interface.
volatile uint8_t DebugPacketOn
flag to enable debug packet
#define CHX
Used to access X-channel entries in various data data structures.
Provides functions to store calibration to NVM.
MagBuffer MagBuffer
mag cal constellation points
volatile uint8_t RPCPacketOn
flag to enable roll, pitch, compass packet
Quaternion derived from 3-axis accel (tilt)
void EraseAccelCalibrationFromNVM(void)
#define FUSION_HZ
(int) actual rate of fusion algorithm execution and sensor FIFO reads
Defines control sub-system.
void fInitializeAccelCalibration(struct AccelCalibration *pthisAccelCal, struct AccelBuffer *pthisAccelBuffer, volatile int8 *AccelCalPacketOn)
Initialize the accelerometer calibration functions.
SensorFusionGlobals sfg
This is the primary sensor fusion data structure.
#define ACCEL_CAL_AVERAGING_SECS
calibration constants
volatile uint8_t iPerturbation
test perturbation to be applied
volatile quaternion_type QuaternionPacketType
quaternion type transmitted over UART
volatile uint8_t AngularVelocityPacketOn
flag to enable angular velocity packet